$floating-in-height: 3.25em !default;

.field {
    &.is-grouped {
        .field {
            flex-shrink: 0;
            &:not(:last-child) {
                margin-right: 0.75rem;
            }
            &.is-expanded {
                flex-grow: 1;
                flex-shrink: 1;
            }
        }
    }
    // Nested control addons (for Autocomplete and Datepicker)
    &.has-addons .control {
        &:first-child .control {
            .button,
            .input,
            .select select {
                border-bottom-left-radius: $input-radius;
                border-top-left-radius: $input-radius;
            }
        }
        &:last-child .control {
            .button,
            .input,
            .select select {
                border-bottom-right-radius: $input-radius;
                border-top-right-radius: $input-radius;
            }
        }
        .control {
            .button,
            .input,
            .select select {
                border-radius: 0
            }
        }
    }
    // Fix for number input with addons
    &.has-addons {
        .b-numberinput {
            &:not(:first-child) {
                .control:first-child {
                    .button,
                    .input,
                    .select select {
                        border-bottom-left-radius: 0;
                        border-top-left-radius: 0;
                    }
                }
            }
            &:not(:last-child) {
                .control:last-child {
                    .button,
                    .input,
                    .select select {
                        border-bottom-right-radius: 0;
                        border-top-right-radius: 0;
                    }
                }
            }
        }
        &.b-numberinput {
            .control {
                margin-right: unset;
            }
        }
    }
}

.field {
    &.is-floating-label,
    &.is-floating-in-label {
        position: relative;

        .label {
            position: absolute;
            left: 1em;
            font-size: calc(#{$size-normal} * 0.75);
            background-color: transparent;
            z-index: 5;
            white-space: nowrap;
            text-overflow: ellipsis;
            max-width: calc(100% - 2em);
            overflow: hidden;

            &.is-small {
                font-size: calc(#{$size-small} * 0.75);
            }
            &.is-medium {
                font-size: calc(#{$size-medium} * 0.75);
            }
            &.is-large {
                font-size: calc(#{$size-large} * 0.75);
            }
        }
        .taginput .counter {
            float: none;
            text-align: right;
        }

        &.has-addons {
            > .label {
                + .control {
                    .button,
                    .input,
                    .select select {
                        border-bottom-left-radius: $input-radius;
                        border-top-left-radius: $input-radius;
                    }
                }
            }
        }
    }

    &.is-floating-label {
        .label {
            top: -0.775em;
            padding-left: 0.125em;
            padding-right: 0.125em;
            &:before {
                content: '';
                display: block;
                position: absolute;
                top: 0.775em;
                left: 0;
                right: 0;
                height: 0.375em;
                background-color: $input-background-color;
                z-index: -1;
            }
        }
        .input,
        .textarea,
        .select
        select {
            &:focus {
                box-shadow: none;
            }
        }
        .taginput .taginput-container {
            padding-top: 0.475em;
            &.is-focused {
                box-shadow: none;
            }
        }
    }
    &.is-floating-in-label {
        > .label {
            top: 0.25em;

            + .control {
                &.datepicker, &.timepicker {
                    .input {
                        padding-top: calc(#{$floating-in-height} * 0.5 - (#{$size-large} * 0.75) * 0.5);
                        padding-bottom: 1px;
                        height: $floating-in-height;
                    }
                }
                &:not(.datepicker):not(.timepicker):not(.taginput) {
                    .input,
                    .textarea,
                    select {
                        padding-top: calc(#{$floating-in-height} * 0.5 - (#{$size-large} * 0.75) * 0.5);
                        padding-bottom: 1px;
                        height: $floating-in-height;
                    }
                    .select:not(multiple) {
                        height: $floating-in-height;
                        &.is-loading {
                            &::after {
                                margin-top: calc(#{$floating-in-height} * 0.5 - (#{$size-large} * 0.75) * 0.5);
                            }
                        }
                        &::after {
                            margin-top: 1px;
                        }
                    }
                }
                &.taginput {
                    .taginput-container {
                        // 0.275em - 1px _taginput.scss
                        padding-top: calc(#{$floating-in-height} * 0.5 - (#{$size-large} * 0.75) * 0.5 + (0.275em - 1px));
                    }
                }
                &:not(.taginput) {
                    .is-left.icon,
                    .is-right.icon {
                        height: $floating-in-height;
                    }
                    .is-left.icon {
                        padding-top: calc(#{$floating-in-height} * 0.5 - (#{$size-large} * 0.75) * 0.5);
                    }
                }
                &.is-loading::after {
                    margin-top: calc(#{$floating-in-height} * 0.5 - (#{$size-large} * 0.75) * 0.5);
                }
            }

            // With addons or grouped
            + .field-body {
                > .is-grouped, > .has-addons {
                    .control {
                        .input,
                        .textarea,
                        select {
                            padding-top: calc(#{$floating-in-height} * 0.5 - (#{$size-large} * 0.75) * 0.5);
                            padding-bottom: 1px;
                        }
                        .input,
                        .textarea,
                        select,
                        .button {
                            height: $floating-in-height;
                        }
                    }
                }
            }
        }

        &.has-numberinput {
            .b-numberinput {
                .control {
                    .input,
                    .button {
                        height: $floating-in-height;
                    }
                }
            }
        }
    }
    &.is-floating-label, &.is-floating-in-label {
        &.has-numberinput {
            .label {
                margin-left: calc(#{$size-normal} * 3);
            }
            &.has-numberinput-is-small {
                .label {
                    margin-left: calc(#{$size-small} * 3);
                }
            }
            &.has-numberinput-is-medium {
                .label {
                    margin-left: calc(#{$size-medium} * 3);
                }
            }
            &.has-numberinput-is-large {
                .label {
                    margin-left: calc(#{$size-large} * 3);
                }
            }
        }
        &.has-numberinput-compact {
            .label {
                margin-left: calc(#{$size-normal} * 2.25);
            }
            &.has-numberinput-is-small {
                .label {
                    margin-left: calc(#{$size-small} * 2.25);
                }
            }
            &.has-numberinput-is-medium {
                .label {
                    margin-left: calc(#{$size-medium} * 2.25);
                }
            }
            &.has-numberinput-is-large {
                .label {
                    margin-left: calc(#{$size-large} * 2.25);
                }
            }
        }
    }
    &.is-grouped-right, &.has-addons-right {
        &.is-floating-in-label {
            .label {
                position: relative;
                left: calc(3.25em + 2em);
            }
        }
        &.is-floating-label {
            .label {
                position: relative;
                left: calc(3.25em + 2em);
            }
        }
    }
}

.control {
    .help.counter {
        float: right;
        margin-left: 0.5em;
    }
    .icon {
        &.is-clickable {
            pointer-events: auto;
            cursor: pointer;
        }
    }
    // fix Bulma 0.8.2
    &.is-loading::after {
        top: calc(50% - (1em * 0.5));
        right: calc((2.5em * 0.5) - .5em);
    }
}
